home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
mgabra.zip
/
MGABRA.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-01
|
39KB
|
1,177 lines
PAGE 55,132
TITLE ABRACADABRA! MAGIC SOFTWARE TSR/TCR (Terminate Cont Running) LIBRARY
INCLUDE MGMMACS.ASM
DEINT EQU 0e0h ;Deinstall Interrupt
STKSAV EQU 32
INCLUDE MGLANGC.ASM
;------------------------------------------------
; SEGMENT DEFINITIONS
;------------------------------------------------
EXTRN __psp:WORD
_BSS SEGMENT WORD PUBLIC 'BSS'
_BSS ENDS
DGROUP GROUP _DATA, _BSS
_DATA SEGMENT WORD PUBLIC 'DATA'
ASSUME DS:DGROUP, SS:DGROUP
_DATA ENDS
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
EXTRN _tsrexit:FAR
;------------------------------------------------
; PUBLICS - Functions you can call
;------------------------------------------------
PUBLIC _swpscr
PUBLIC _hotkey
PUBLIC _timer
PUBLIC _swap
PUBLIC _tsrset
PUBLIC _swping
PUBLIC _swapno
PUBLIC _swapyes
PUBLIC _status
PUBLIC _id
PUBLIC _putchr
PUBLIC _conout
PUBLIC _inkey
PUBLIC _bykey
;-----------------------------------------------------
; TCB (Task Control Blocks)
; Areas where various info about the processs are kept
;-----------------------------------------------------
dosprg dw 60 dup (0) ;TCB for TSR program
tsrprg dw 60 dup (0) ;TCB for Interrupted program
dosprgs db 4000 dup (0) ;area for saving TSR's screen
tsrprgs db 4000 dup (0) ;area for saving interrupted's screen
swptog dw 0 ;swapping disabled? 1 = yes
scrswp dw 0 ;screen swap mode
timed dw 0 ;time triggering on? 1 = yes
by28 dw 0 ;invoked within int28 call?
keyswap dw 0 ;was swapping done on key control?
keypop dw 0 ;last swap by key? (retained)
period dw 0 ;how many 1/18sec do we run for?
doswap dw 0 ;"I want to swap" flag
inproc dw 0 ;busy swapping processes flag
hard_bz dw 0 ;hardware busy flag
flag_28 dw 0 ;interrupt 28 live
prob28h dw 0 ;is int28 a problem? 0 = yes
videosz dw 0 ;size of video screen
videos dw 0 ;dynamic base of video seg
videom dw 0 ;current video mode
videop dw 0 ;current video page
procid dw 0 ;this programs id number
stflag dw 0 ;polled status
errflag dw 0 ;critical error number
envadd dw 0 ;paragraph of environment
entry dw 0 ;IP of TSR upon initialization
indoss dw 0 ;dos busy flag segment
indoso dw 0 ;dos busy flag offset
init dw 0 ;TSR initialized?
savpar dw 0 ;paragraphs to save
add6845 dw 0 ;address of 6845 video controller
color dw 0b800h ;base of color video area
mono dw 0b000h ;base of monochrome video area
hotkey db 0 ;hotkey scan code
hotstat db 0 ;hot key shift key
err0 db 'ABRACADABRA ERROR: $'
err1 db 'Not Enough Memory$'
err2 db 'Illegal Use of DOS Function Below 0CH$'
err3 db 'Insufficient Memory - Language Does Not Return Excess to Dos$'
err4 db 'Synchronization$'
hithere db 'Source Code Is Available Dude! Walt Howard 213-477-4151'
coprght db 'Copyright (c) 1988 by Walter F. Howard Jr.'
vrsn db '1.2 For TURBO C ONLY!'
;-------------------------------------------------------
; DOS interrupt values
; Here is where the old interrupt vectors are kept saved
;-------------------------------------------------------
disk_int label dword ;int 13h (disk) vector
old_13h dw 2 dup(?)
vid_int label dword ;int 10h (video) vector
old_10h dw 2 dup(?)
timer_int label dword ;int 1ch vector
old_timer dw 2 dup(?)
key_int label dword ;int 9h vector
old_key dw 2 dup(?)
back_int label dword ;int 28h vector
old_28h dw 2 dup(?)
clear_int label dword ;clear out tsr interrupt
old_clr dw 2 dup(?)
;------------------------------------------------
; INTERRUPT HANDLERS
;------------------------------------------------
;------------------------------------------------
; stime - every timer tick (1/18sec) comes here
;------------------------------------------------
stime proc far
sti
pushf
call timer_int ;pass on vector for others first
cmp timed, -1 ;Is time triggering enabled?
jne time1 ;no then don't do rest of this block
cmp doswap, 1 ;want to swap?
je time1 ;yes then skip next section
dec period ;count down
cmp period, 0 ;is it zero yet?
jg time1 ;if no then skip next
mov doswap, 1 ;if yes then set doswap on
time1:
cmp swptog, 1 ;is swapping disabled?
jne time2 ;no? then continue
jmp far ptr time9 ;else exit
time2:
cmp doswap, 1 ;is doswap on
je time3 ;yes jump into next check
jmp far ptr time9 ;else exit
time3:
cmp inproc, 0 ;are we already engaged?
je time4 ;no then proceed to next check
jmp far ptr time9 ;else jump out
time4:
mov inproc, 1 ;signal we are engaged
cmp hard_bz, 0 ;bios service in progress?
je time5 ;no then proceed to next check
jmp far ptr time8 ;else exit
time5:
cmp prob28h, 0 ;int 28 a problem? (0 = yes)
je time6 ;yes, goto check dos busy
cmp flag_28, 0 ;else, is int 28 in progress?
je time6 ;no, check for dos busy
cmp by28, 1 ;are we currently active on a 28 int?
je time7 ;good! we can interrupt without
;checking dos busy if TSR written
;to not use dos below 0ch
time6:
push es ;save ES and DI
push di
mov es,indoss ;get DOS segment in ES
mov di,indoso ;address of DOS BUSY_FLAG in DI
cmp byte ptr es:[di],0 ;DOS service currently active?
pop di ;clean up
pop es
je time7 ;not busy enter SWAP routine
jmp far ptr time8 ;else, exit
time7:
jmp far ptr swpprc
time8:
mov inproc, 0 ;no longer in process
time9:
cmp by28, 0
je time10
int 28h
time10:
iret
stime endp
;-----------------------------------------------------------------
; bakprc - interrupt 28 spooler interrupt almost as good as timer
;-----------------------------------------------------------------
bakprc proc far
sti
pushf
call back_int ;pass it on for others first
mov flag_28, 1 ;signal that int 28 in progress
cmp prob28h, 0 ;Will we be using dos funcs below 0ch?
jne bak1 ;no? good, jump to next check
mov flag_28, 0 ;otherwise no go, have to deny
iret ;return to calling process
bak1: